#ifndef OELOCALACCOUNT_H
#define OELOCALACCOUNT_H

#include <QObject>
#include <QSqlDatabase>

class OESuperManagerSqlDatabase;
class OELocalAccount : public QObject
{
    Q_OBJECT
protected:

    /// local account base info
    struct stUserInfo{
        QString user;
        QString pswd;
        QString name;
    };

    friend class OESuperManagerSqlDatabase;
public:
    explicit OELocalAccount(QObject *parent = 0);

    int open(const QString& _dbFileName);

    int close(void);

    int setTableName(const QString& _tableName);

    /**
    * brief: login
    * param: out_name  return login user name
    * return: 0 success, not 0 failed
    */
    virtual int login(const QString& _user,
              const QString& _pswd,
              QString& out_name);


    bool isLogin(void);


    /**
    * brief: log out
    * return: 0 success, not 0 failed
    */
    virtual int logout(void);


    /**
    * brief: check super manager pswd
    * return: 0 success, not 0 failed
    */
    int checkPswd(const QString& _pswd);



protected:


protected:

    QSqlDatabase db_;

private:

    stUserInfo info_;
    QString tableName_;

};

#endif // OELOCALACCOUNT_H
